package com.wehealth.adapter;

import java.util.List;

import com.wehealth.R;
import com.wehealth.dm.DM_PlanDay;
import com.wehealth.dm.QuestionData;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Adapter_QuestionReply extends BaseAdapter {

	/**
	 * 上下文
	 */
	private Context ctx;
	//private int[] layout ={R.layout.question_reply_owner,R.layout.question_reply_doctor};
	//private int[] timeTVid ={R.id.question_reply_owner_time,R.id.question_reply_doctor_time};
	//private int[] descripTVid ={R.id.question_reply_owner_descrip,R.id.question_reply_doctor_descrip};
	/**
	 * 列表数据
	 */
	private List<QuestionReplyDate> theList;
	
	public Adapter_QuestionReply(Context ctx,List<QuestionReplyDate> theList){
		this.ctx = ctx;
		this.theList = theList;
	}

	@Override
	public int getCount() {
		return theList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		 int[] layout ={R.layout.question_reply_owner,R.layout.question_reply_doctor};
		 int[] timeTVid ={R.id.question_reply_owner_time,R.id.question_reply_doctor_time};
		 int[] descripTVid ={R.id.question_reply_owner_descrip,R.id.question_reply_doctor_descrip};
		String isDr = theList.get(arg0).getisDr();
		int  id = 0;
		if(!isDr.equals("0")){
			 id = 1;
		}
		Log.d("SIMMON","id="+id);
		View view = LayoutInflater.from(ctx).inflate(layout[id],null);	
		TextView time = (TextView)view.findViewById(timeTVid[id]);
		Log.d("SIMMON","time="+time);
		Log.d("SIMMON","theList.get(arg0).getTime()="+theList.get(arg0).getTime());
		time.setText( theList.get(arg0).getTime());

	   TextView descrption = (TextView)view.findViewById(descripTVid[id]);
	   descrption.setText(theList.get(arg0).getReply());
		return view;
	}

}